package com.nolon.flange.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.nolon.flange.model.Project

@Dao
interface ProjectDao {

    @Insert
    suspend fun insert(project: Project): Long

    @Insert
    suspend fun insertAll(projects: List<Project>)

    @Delete
    suspend fun delete(project: Project)

    @Update
    suspend fun update(project: Project)

    @Query("SELECT * FROM project_table WHERE id = :id")
    suspend fun getProject(id: Int): Project

//    @Query("DELETE FROM project_table")
//    suspend fun deleteAll(projects: List<Project>)

    @Query("SELECT * FROM project_table ORDER BY modified DESC")
    fun getAll(): LiveData<List<Project>>

    @Query("DELETE  FROM project_table WHERE id = :id ")
    suspend fun deleteById(id: Int)

    @Query("SELECT * FROM project_table WHERE id = :id")
    fun getProjectLive(id: Int):LiveData<Project>

}
